package edu.unindra.elearning;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

import jxl.Cell;
import jxl.CellType;
import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;

public class ReadFileExcel {
	private String inputFile;

	public void setInputFile(String inputFile) {
		this.inputFile = inputFile;
	}

	public void read() throws IOException {
		FileInputStream inputWorkbook = new FileInputStream(new File(inputFile));
		// File inputWorkbook = new File(inputFile);
		Workbook w;
		try {
			w = Workbook.getWorkbook(inputWorkbook);

			// Get the first sheet
			Sheet sheet = w.getSheet(0);
			// Loop over first 10 column and lines

			System.out.println("Row ==> : " + (sheet.getRows() - 9)
					+ ", Colums ===>" + sheet.getColumns());
			for (int i = 4; i < sheet.getRows(); i++) {
				if (i % 2 == 0) {
					for (int j = 1; j < 7; j++) {
						Cell cell = sheet.getCell(j, i);

						CellType type = cell.getType();
						System.out.println(i + " ===> " + cell.getContents());

					}
				}

			}

		} catch (BiffException e) {
			e.printStackTrace();
		}
	}

	public static void main(String[] args) throws IOException {
		ReadFileExcel test = new ReadFileExcel();
		test.setInputFile("D:/Private/Campus/Skripsi/Monitoring/skripsi/Temp/Data/JurnalPeriodeFebruari2014.xls");
		test.read();
	}

}
